<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateImageShowTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('image_show', function (Blueprint $table) {
            $table->increments('id');

            $table->unsignedInteger('show_id')->index();
            $table->foreign('show_id')->references('id')->on('shows');

            $table->unsignedInteger('image_id')->index();
            $table->foreign('image_id')->references('id')->on('images');
        });

        Schema::table('shows', function($table)
        {
            $table->smallInteger('score');
            $table->integer('vote');
        });

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('image_show');
        

        Schema::table('shows', function($table)
        {
            $table->dropColumn('vote','score');
        });

    }
}
